package com.gomoku.backend.service.impl.pk;

import com.gomoku.backend.consumer.WebSocketServer;
import com.gomoku.backend.consumer.utils.Game;
import com.gomoku.backend.service.pk.ReceiveBotMoveSerice;
import org.springframework.stereotype.Service;

@Service
public class ReceiveBotMoveSeviceImpl implements ReceiveBotMoveSerice {
    @Override
    public String botmove(Integer userId,Integer botId,Integer r, Integer c) {
        //System.out.println("botId: "+botId+" row:"+r+" col:"+c);
        //这里设置 AI的落棋
        Game game = WebSocketServer.users.get(userId).game;
        //只需要管userId就行了，botId是没有websocket
        //其实是对playerB set r c进行设置nextStepB =true;
        game.setNextStepB(true);
        game.setPlayerB(c,r);
        game.getBoard()[r][c] = game.getCurrentPlayer();
        return "receive botmove success";
    }
}